package com.hoshiibuy.cas.client.session;

import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.SessionContext;
import org.apache.shiro.session.mgt.SessionFactory;

import com.hoshiibuy.configuration.HoshiibuyConfiguration;

/**
 * Session生成器
 */
public class HoshiibuyCasSessionFactory implements SessionFactory {
    public HoshiibuyCasSessionFactory(){}

    private HoshiibuyConfiguration hoshiibuyConfiguration;
    public HoshiibuyCasSessionFactory(HoshiibuyConfiguration hoshiibuyConfiguration){
        this.hoshiibuyConfiguration = hoshiibuyConfiguration;
    }
    @Override
    public Session createSession(SessionContext sessionContext) {
        HoshiibuyCasSession session = new HoshiibuyCasSession();
        session.setServerName(hoshiibuyConfiguration.getSys().getServerName());
        session.setHost(sessionContext.getHost());
        session.setTimeout(hoshiibuyConfiguration.getCas().getClientSessionTimeout());
        return session;
    }
}
